package io.jft.doll.ui.room.bind

import android.view.View
import com.alibaba.android.arouter.launcher.ARouter
import com.g.base.extend.date
import com.g.base.ui.recyclerView.item.BaseItem
import io.jft.doll.R
import io.jft.doll.databinding.ItemRoomRankRecentBinding
import io.jft.doll.room.entity.remote.RoomGameRankRecentREntity
import io.jft.doll.router.RouterPage

/**
 * Created by G on 2017/12/21 0021.
 */
class RoomRankRecentBind(val item: RoomGameRankRecentREntity, val rank: Int) : BaseItem<ItemRoomRankRecentBinding>() {
    override val layoutId: Int = R.layout.item_room_rank_recent
    var rankColor = R.color.colorTextDarkWeek
    var tip = ""

    override fun onBind(binding: ItemRoomRankRecentBinding) {
        if (rank > 0) {
            rankColor = binding.root.resources.getColor(when (rank) {
                1 -> R.color.colorRank1
                2 -> R.color.colorRank2
                3 -> R.color.colorRank3
                else -> R.color.colorTextDarkWeek
            })
            tip = "${item.amount}次"
        } else {
            tip = item.date.date()
        }
    }

    override fun onClick(view: View) {
        ARouter.getInstance().build(RouterPage.DollActivity)
                .withString("userName", item.nickName)
                .withString("thumbnail", item.thumbnail)
                .withString("userId", item.userId)
                .navigation(view.context)
    }
}
